<!DOCTYPE html>
<html>
<head>
  <title>OrderService.java</title>
  <meta http-equiv='Content-Type' content='text/html; charset=UTF-8'/>
  <link rel='stylesheet' type='text/css' href='../../../../../coverage.css'/>
  <link rel='shortcut icon' type='image/png' href='../../../../../logo.png'/>
  <script type='text/javascript' src='../../../../../coverage.js'></script>
  <script type='text/javascript' src='../../../../../prettify.js'></script>
</head>
<body onload='prettyPrint()'>
  <table cellpadding='0' cellspacing='1'>
    <caption>jmokit-demo\src\main\java\com\example\jmokit\service\impl\OrderService.java</caption>
    <tr>
      <td class='line'>1</td><td>&nbsp;</td>
      <td><pre class='prettyprint'>package com.example.jmokit.service.impl;</pre></td>
    </tr>
    <tr><td class='line'></td><td colspan='2'>&nbsp;</td></tr>
    <tr>
      <td class='line'></td><td>&nbsp;</td>
      <td><pre class='imports prettyprint' onclick='showHideLines(this)'><div>import com.example.jmokit.service.MailService;
import com.example.jmokit.service.UserCheckService;

import javax.annotation.Resource;
</div><span>import ...</span></pre></td>
    </tr>
    <tr><td class='line'></td><td colspan='2'>&nbsp;</td></tr>
    <tr>
      <td class='line'>8</td><td>&nbsp;</td>
      <td><pre class='prettyprint'>public class OrderService {</pre></td>
    </tr>
    <tr>
      <td class='line'>9</td><td>&nbsp;</td>
      <td><pre class='comment'>    // 邮件服务类，用于向某用户发邮件。</pre></td>
    </tr>
    <tr>
      <td class='line'>10</td><td>&nbsp;</td>
      <td><pre class='prettyprint'>    MailService <span class='instance uncovered' title='Reads: 0 Writes: 0'>mailService</span>;</pre></td>
    </tr>
    <tr>
      <td class='line'>11</td><td>&nbsp;</td>
      <td><pre class='comment'>    // 用户身份校验类，用于校验某个用户是不是合法用户</pre></td>
    </tr>
    <tr>
      <td class='line'>12</td><td>&nbsp;</td>
      <td><pre class='prettyprint'>    @Resource</pre></td>
    </tr>
    <tr>
      <td class='line'>13</td><td>&nbsp;</td>
      <td><pre class='prettyprint'>    UserCheckService <span class='instance uncovered' title='Reads: 0 Writes: 0'>userCheckService</span>;</pre></td>
    </tr>
    <tr><td class='line'></td><td colspan='2'>&nbsp;</td></tr>
    <tr>
      <td class='line'>15</td><td>&nbsp;</td>
      <td><pre class='comment'>    // 构造函数</pre></td>
    </tr>
    <tr>
      <td class='line'>16</td><td>&nbsp;</td>
      <td><pre class='prettyprint'>    public OrderService(MailService mailService) {</pre></td>
    </tr>
    <tr>
      <td class='line'>17</td><td>&nbsp;</td>
      <td><pre class='prettyprint'>        this.mailService = mailService;</pre></td>
    </tr>
    <tr>
      <td class='line'>18</td><td>&nbsp;</td>
      <td><pre class='prettyprint'>    }</pre></td>
    </tr>
    <tr><td class='line'></td><td colspan='2'>&nbsp;</td></tr>
    <tr>
      <td class='line'></td><td>&nbsp;</td>
      <td class='comment' onclick='showHideLines(this)'><div>    /**
     * 下订单
     *
     * @param buyerId
     *            买家ID
     * @param itemId
     *            商品id
     * @return 返回 下订单是否成功
     */</div><span>    /*...*/</span></td>
    </tr>
    <tr>
      <td class='line'>29</td><td>&nbsp;</td>
      <td><pre class='prettyprint'>    public boolean submitOrder(long buyerId, long itemId) {</pre></td>
    </tr>
    <tr>
      <td class='line'>30</td><td>&nbsp;</td>
      <td><pre class='comment'>        // 先校验用户身份</pre></td>
    </tr>
    <tr>
      <td></td><td class='count'>0</td>
      <td class='paths'>
        <span style='cursor:default; background-color:#ff0000' onclick='hidePath()'>Path coverage: 0/3</span>
        <span class='uncovered' onclick="showPath(this,'l31s0 l33s0')">A: 0</span>
        <span class='uncovered' onclick="showPath(this,'l31s0 l38s0 l40s0')">B: 0</span>
        <span class='uncovered' onclick="showPath(this,'l31s0 l38s0 l42s0')">C: 0</span>
      </td>
    </tr>
    <tr>
      <td class='line'>31</td><td>&nbsp;</td>
      <td><pre class='prettyprint'>        if (!userCheckService.check(buyerId)) {</pre></td>
    </tr>
    <tr>
      <td class='line'>32</td><td>&nbsp;</td>
      <td><pre class='comment'>            // 用户身份不合法</pre></td>
    </tr>
    <tr>
      <td class='line'>33</td><td>&nbsp;</td>
      <td><pre class='prettyprint'>            return false;</pre></td>
    </tr>
    <tr>
      <td class='line'>34</td><td>&nbsp;</td>
      <td><pre class='prettyprint'>        }</pre></td>
    </tr>
    <tr>
      <td class='line'>35</td><td>&nbsp;</td>
      <td><pre class='comment'>        // 下单逻辑代码，</pre></td>
    </tr>
    <tr>
      <td class='line'>36</td><td>&nbsp;</td>
      <td><pre class='comment'>        // 省略...</pre></td>
    </tr>
    <tr>
      <td class='line'>37</td><td>&nbsp;</td>
      <td><pre class='comment'>        // 下单完成，给买家发邮件</pre></td>
    </tr>
    <tr>
      <td class='line'>38</td><td>&nbsp;</td>
      <td><pre class='prettyprint'>        if (!this.mailService.sendMail(buyerId, "下单成功")) {</pre></td>
    </tr>
    <tr>
      <td class='line'>39</td><td>&nbsp;</td>
      <td><pre class='comment'>            // 邮件发送成功</pre></td>
    </tr>
    <tr>
      <td class='line'>40</td><td>&nbsp;</td>
      <td><pre class='prettyprint'>            return false;</pre></td>
    </tr>
    <tr>
      <td class='line'>41</td><td>&nbsp;</td>
      <td><pre class='prettyprint'>        }</pre></td>
    </tr>
    <tr>
      <td class='line'>42</td><td>&nbsp;</td>
      <td><pre class='prettyprint'>        return true;</pre></td>
    </tr>
    <tr>
      <td class='line'>43</td><td>&nbsp;</td>
      <td><pre class='prettyprint'>    }</pre></td>
    </tr>
    <tr>
      <td class='line'>44</td><td>&nbsp;</td>
      <td><pre class='prettyprint'>}</pre></td>
    </tr>
  </table>
</body>
</html>
